from selenium import webdriver
from selenium.webdriver.common.by import By
import time


class Login:
    def __init__(self):
        self.driver = webdriver.Chrome()

    # 登录qq邮箱
    def qq_email(self):
        # 打开qq邮箱登录界面
        self.driver.get('https://mail.qq.com/')
        # 切换到登录框架
        self.driver.switch_to.frame('login_frame')
        # 输入账号密码，并点击登录
        self.driver.find_element(By.ID, 'u').send_keys('******')
        time.sleep(2)
        self.driver.find_element(By.ID, 'p').send_keys('**888****')
        self.driver.find_element(By.ID, 'login_button').click()

    
    # 登录163邮箱
    def wangyi_email(self):
        # 打开163邮箱登录页面
        self.driver.get('https://mail.163.com/')
        # 切换到登录框架
        f1 = self.driver.find_element(By.TAG_NAME, 'iframe')
        self.driver.switch_to.frame(f1)
        # self.driver.switch_to.frame('normalLoginTab')
        # 输入账号密码，并点击登录
        self.driver.find_element(By.NAME, 'email').send_keys('****')
        self.driver.find_element(By.NAME, 'password').send_keys('*8*88****')
        self.driver.find_element(By.ID, 'dologin').click()
    

    def quit(self):
        time.sleep(2)
        self.driver.quit()


if __name__ == '__main__':
    b = Login()
    # b.qq_email()
    b.wangyi_email()
    b.quit()
